<?php

require_once dirname(__FILE__).'/config.php';

$template = 'form';
$sform = new GenderSelectForm(); // Форма 

if (isset($_GET['gender'])) {
	$gender = $_GET['gender'];
	$sform->bind(array('gender' => $gender));
	if ($sform->isValid()) {
		$mform = new GenderMailForm($mailConfig, $gender=='m'? 'Мужчина' : 'Женщина');
		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
			$mform->bind($_POST);
			if ($mform->isValid()) {
				$mform->mail();
				$template = 'confirmation';
			}
		}
	}
}

$form = isset($mform)? $mform : $sform;
